package com.sz.biz.logistics.base.service.impl;

import com.sz.biz.logistics.base.entity.FlightDetail;
import com.sz.biz.logistics.base.service.FlightDetailService;
import com.sz.biz.logistics.base.dto.FlightDetailDto;
import com.sz.common.base.service.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Function: FlightDetailService <br>
 * Author: wentao.chang <br>
 * Date: 2017-08-21 15:47:00
 */
@Service("flightDetailService")
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class FlightDetailServiceImpl extends AbstractService implements FlightDetailService {
    @Override
    public void save(List<FlightDetailDto> flightDetailDto) {
        dao.batchInsert("FlightDetailMapper.insert",flightDetailDto);
    }

    /**
     * 根据flightId删除明细
     *
     * @param flightId flightId
     */
    @Override
    public void deleteByFlightId(Integer flightId) {
        dao.delete("FlightDetailMapper.deleteByFlightId",flightId);
    }

    /**
     * 根据id查询航班信息
     *
     * @param flightId flightId
     * @return FlightDto
     */
    @Override
    public List<FlightDetail> findByFlightId(Integer flightId) {
        return dao.findForList("FlightDetailMapper.selectByFlightId",flightId,FlightDetail.class) ;
    }
}
